set more off
cap log close
cap clear all
set maxvar 30000
set matsize 11000

** Relevant directories
global path "N:\MedicareClaims-P045601-BE\Work\"
global hrpath "N:\MedicareClaims-P045601-BE\Work\hosp_retro"
global dpath "N:\MedicareClaims-P045601-BE\Work\ay_data"
global tpath "N:\MedicareClaims-P045601-BE\Work\hosp_retro\stata_do"
global nwpath "N:\MedicareClaims-P045601-BE\Work\hosp_retro\Nathan\Data"

log using "$hrpath\Nathan\Logs\sample merger list.txt", replace t 


* restrict merger info to just vertical mergers
	use "$nwpath\merger_info.dta", clear
	merge m:1 ID using "$nwpath\vertical_merger_list.dta"
	keep if _m == 3
	drop _m
	tempfile vertmergers
	save `vertmergers', replace

* estimated mergers
	use "$nwpath/base_estimates.dta", clear
	gen ID = merger
	tempfile temp
	save `temp', replace

use `vertmergers', clear

keep ID sysdum cardio repeater num_hosp Target Buyer Ann 
duplicates drop

merge 1:m ID using `temp'
keep if _m == 3

keep ID Target Buyer Ann repeater num_
duplicates drop
format Ann %td
br

export excel using "N:\MedicareClaims-P045601-BE\Work\hosp_retro\Nathan\Output\merger_list.xls", replace
